import Vue from "vue";
import App from "./App.vue";
// 引入Vuex
import store from "./store/";
// 引入Element UI
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
// 引入JH 管理系统字体图标
import "./assets/overall/css/iconfont.css";
// 引入Axios
import http from "./tools/http.js";
// 引入Echarts
import * as echarts from "echarts";
// 引入路由器配置
import router from "./router/";
// 引入請求地址
import api from "./tools/api.js";
// 引入七牛
// import QiNiu from "./tools/qiniu";

// QiNiu.upload()

// Vue.prototype.$QiNiu = QiNiu;
Vue.prototype.$echarts = echarts;
Vue.prototype.$api = api;
Vue.prototype.$axios = http;
// Vue.prototype.Im = WebIm
Vue.config.productionTip = false;
// 安裝Element ui
Vue.use(ElementUI);
Vue.filter("handleGender", (gender) => {
  let genderArray = [
    { code: 0, value: "保密" },
    { code: 1, value: "男" },
    { code: 2, value: "女" },
  ];
  return genderArray.find((item) => item.code == gender).value;
});

// 公用时间戳过滤器
Vue.filter("turnTime", function (time) {
  let now = new Date(time);
  // 时间返回格式
  let mode = 3;
  // 年
  let year = now.getFullYear();
  // 月
  let month = now.getMonth() + 1;
  // 日
  let day = now.getDate();
  // 时
  let hour = now.getHours();
  // 分
  let minute = now.getMinutes();
  // 秒
  let second = now.getSeconds();
  if (mode == 0) {
    // 返回格式：   *年*月*日 *：*：*
    return `${year}年${month}月${day}日 ${hour}:${minute}:${second}`;
  } else if (mode == 1) {
    // 返回格式：   *年*月*日
    return `${year}年${month}月${day}日`;
  } else if (mode == 2) {
    // 返回格式：   *-*-*- *：*：*
    return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  } else if (mode == 3) {
    // 返回格式：   *-*-*-
    return `${year}-${month}-${day}`;
  }
});

// 公用评分过滤器
Vue.filter("turnStar", function (star) {
  return star;
});
// 手机号码中间隐藏
Vue.filter("phoneShow", function (val) {
  if (val) {
    let phone = val.toString();
    let phoneArray = phone.split("");
    let newPhone = phoneArray.map((item, index) => {
      if (index >= 3 && index <= 7) {
        return "*";
      } else {
        return item;
      }
    });
    return newPhone.join("");
  } else {
    return "未绑定";
  }
});

// 引入 Table分组 组件
import tableMake from "./components/tabel-make/tabel-make.vue";
// 注册全局 Table分组 组件
Vue.component("tableMake", tableMake);

new Vue({
  store: store,
  router: router,
  render: (h) => h(App),
}).$mount("#app");
